

#define DSG_TEMPERATURE_TABLE_SECTIONS      4
#define RESIDUAL_DSG_1st_TEMPERATURE_INDEX  0
#define RESIDUAL_DSG_2nd_TEMPERATURE_INDEX  1
#define RESIDUAL_DSG_3rd_TEMPERATURE_INDEX  2
#define RESIDUAL_DSG_4th_TEMPERATURE_INDEX  3



#define DSG_OCV_TABLE_POINTS 41
#define DSG_NUM_OF_OCV_LINE  7

#define RESIDUAL_DSG_CAPACITY_INDEX     0
#define RESIDUAL_DSG_1st_CURRENT_INDEX  1
#define RESIDUAL_DSG_2nd_CURRENT_INDEX  2
#define RESIDUAL_DSG_3rd_CURRENT_INDEX  3
#define RESIDUAL_DSG_4th_CURRENT_INDEX  4
#define RESIDUAL_DSG_5th_CURRENT_INDEX  5
#define RESIDUAL_DSG_6th_CURRENT_INDEX  6
#define RESIDUAL_DSG_7th_CURRENT_INDEX  7


/*
; TERMINAL_VOLTAGE units is mV
; RESIDUAL_CAPACITY units is percentage
; Please sort from largest to smallest
// 2600mAh cell
*/

const unsigned int DSG_TEMPERATURE_OCVTable[DSG_TEMPERATURE_TABLE_SECTIONS][DSG_OCV_TABLE_POINTS][DSG_NUM_OF_OCV_LINE+1] =
{
    {// 1st Dim
        ////////////// RESIDUAL CAPACITY  at -5 degrees /////////////////////////////////////////////////////////////////////////////////////////////////
        //     Capacity,        1st mV              2nd mV              3rd mV          4th mV          5th mV              6th mV          7th mV
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Current-15.6Ah,6P     <= 5.0A             5.0~6.0A          6.0~7.8A         7.8~9.9A        9.9~11.9A          11.9~13.9A       13.9~16.7A             
        //Current-18.2Ah,7P     <= 6.0A             6.0~7.0A          7.0~9.1A         9.1~11.7A       11.7~14.0A         14.0~16.3A       TBD: >16.3A             
        //  SOC%,               Pack V,             Pack V,           Pack V,           Pack V,         Pack V,           Pack V,          Pack V,
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        {    10000   ,          41850,              41850,            41850,           41850,           41850,            41850,           41850    },    // index = 00 
        {    9750    ,          39464,              39115,            38764,           38497,           38144,            37873,           37284    },    // index = 01 
        {    9500    ,          39020,              38646,            38265,           37971,           37581,            37275,           36635    },    // index = 02 
        {    9250    ,          38846,              38483,            38109,           37815,           37425,            37114,           36481    },    // index = 03 
        {    9000    ,          38668,              38319,            37946,           37645,           37259,            36947,           36325    },    // index = 04 
        {    8750    ,          38515,              38179,            37804,           37490,           37111,            36803,           36195    },    // index = 05 
        {    8500    ,          38356,              38033,            37657,           37331,           36958,            36654,           36057    },    // index = 06 
        {    8250    ,          38202,              37888,            37518,           37193,           36823,            36518,           35919    },    // index = 07 
        {    8000    ,          38043,              37738,            37373,           37049,           36682,            36376,           35774    },    // index = 08 
        {    7750    ,          37904,              37607,            37249,           36929,           36559,            36245,           35648    },    // index = 09 
        {    7500    ,          37778,              37492,            37141,           36824,           36449,            36124,           35537    },    // index = 10 
        {    7250    ,          37656,              37377,            37029,           36712,           36335,            36002,           35423    },    // index = 11 
        {    7000    ,          37546,              37276,            36927,           36600,           36225,            35893,           35323    },    // index = 12 
        {    6750    ,          37451,              37190,            36836,           36495,           36126,            35799,           35236    },    // index = 13 
        {    6500    ,          37357,              37104,            36752,           36408,           36046,            35725,           35170    },    // index = 14 
        {    6250    ,          37287,              37040,            36696,           36358,           36005,            35692,           35143    },    // index = 15 
        {    6000    ,          37174,              36933,            36595,           36264,           35917,            35609,           35067    },    // index = 16 
        {    5750    ,          37103,              36874,            36543,           36213,           35868,            35557,           35026    },    // index = 17 
        {    5500    ,          36938,              36727,            36403,           36069,           35725,            35405,           34886    },    // index = 18 
        {    5250    ,          36869,              36673,            36354,           36017,           35672,            35346,           34837    },    // index = 19 
        {    5000    ,          36786,              36602,            36287,           35946,           35605,            35277,           34767    },    // index = 20 
        {    4750    ,          36760,              36581,            36268,           35927,           35586,            35258,           34744    },    // index = 21 
        {    4500    ,          36699,              36521,            36207,           35864,           35524,            35196,           34681    },    // index = 22 
        {    4250    ,          36677,              36499,            36185,           35841,           35501,            35172,           34657    },    // index = 23 
        {    4000    ,          36582,              36394,            36067,           35710,           35357,            35017,           34476    },    // index = 24 
        {    3750    ,          36566,              36377,            36051,           35696,           35343,            35003,           34462    },    // index = 25 
        {    3500    ,          36536,              36347,            36022,           35668,           35315,            34975,           34435    },    // index = 26 
        {    3250    ,          36516,              36327,            36000,           35643,           35288,            34946,           34407    },    // index = 27 
        {    3000    ,          36491,              36304,            35972,           35609,           35251,            34905,           34368    },    // index = 28 
        {    2750    ,          36435,              36248,            35912,           35540,           35179,            34829,           34291    },    // index = 29 
        {    2500    ,          36351,              36164,            35822,           35442,           35077,            34724,           34179    },    // index = 30 
        {    2250    ,          36251,              36072,            35727,           35336,           34970,            34612,           34060    },    // index = 31 
        {    2000    ,          36126,              35960,            35615,           35213,           34847,            34485,           33929    },    // index = 32 
        {    1750    ,          35964,              35818,            35476,           35064,           34703,            34338,           33781    },    // index = 33 
        {    1500    ,          35738,              35625,            35290,           34863,           34509,            34139,           33587    },    // index = 34 
        {    1250    ,          35604,              35520,            35189,           34746,           34390,            34004,           33453    },    // index = 35 
        {    1000    ,          35258,              35182,            34848,           34393,           34030,            33632,           33070    },    // index = 36 
        {    750     ,          35051,              34974,            34632,           34165,           33784,            33365,           32776    },    // index = 37 
        {    500     ,          34729,              34657,            34305,           33821,           33415,            32962,           32338    },    // index = 38 
        {    250     ,          33942,              33840,            33503,           33065,           32673,            32248,           31827    },    // index = 39 
        {    0       ,          30000,              30000,            30000,           30000,           30000,            30000,           30000    }     // index = 40 
    },// 1st Dim

    {// 2nd Dim
        ////////////// RESIDUAL CAPACITY  at   5 degrees /////////////////////////////////////////////////////////////////////////////////////////////////
        //     Capacity,        1st mV              2nd mV              3rd mV          4th mV          5th mV              6th mV          7th mV
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Current-15.6Ah,6P     <= 5.0A             5.0~6.0A          6.0~7.8A         7.8~9.9A        9.9~11.9A          11.9~13.9A       13.9~16.7A             
        //Current-18.2Ah,7P     <= 6.0A             6.0~7.0A          7.0~9.1A         9.1~11.7A       11.7~14.0A         14.0~16.3A       TBD: >16.3A             
        //  SOC%,               Pack V,             Pack V,           Pack V,           Pack V,         Pack V,           Pack V,          Pack V,
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        {    10000   ,          41850,              41850,            41850,            41850,           41850,            41850,          41850},    // index = 00 
        {    9750    ,          39764,              39465,            39149,            38897,           38574,            38323,          37834},    // index = 01 
        {    9500    ,          39320,              38996,            38650,            38371,           38011,            37725,          37185},    // index = 02 
        {    9250    ,          39146,              38833,            38494,            38215,           37855,            37564,          37031},    // index = 03 
        {    9000    ,          38968,              38669,            38331,            38045,           37688,            37397,          36875},    // index = 04 
        {    8750    ,          38815,              38529,            38190,            37890,           37541,            37253,          36745},    // index = 05 
        {    8500    ,          38656,              38383,            38042,            37731,           37388,            37104,          36607},    // index = 06 
        {    8250    ,          38502,              38238,            37903,            37593,           37253,            36968,          36469},    // index = 07 
        {    8000    ,          38343,              38088,            37758,            37449,           37112,            36826,          36324},    // index = 08 
        {    7750    ,          38204,              37957,            37634,            37329,           36989,            36695,          36198},    // index = 09 
        {    7500    ,          38078,              37842,            37526,            37224,           36879,            36574,          36087},    // index = 10 
        {    7250    ,          37956,              37727,            37414,            37112,           36765,            36452,          35974},    // index = 11 
        {    7000    ,          37846,              37626,            37312,            37000,           36656,            36343,          35873},    // index = 12 
        {    6750    ,          37751,              37540,            37221,            36895,           36557,            36249,          35786},    // index = 13 
        {    6500    ,          37657,              37454,            37137,            36808,           36477,            36175,          35720},    // index = 14 
        {    6250    ,          37587,              37390,            37081,            36758,           36436,            36142,          35693},    // index = 15 
        {    6000    ,          37474,              37283,            36981,            36664,           36348,            36059,          35617},    // index = 16 
        {    5750    ,          37403,              37224,            36929,            36613,           36299,            36007,          35576},    // index = 17 
        {    5500    ,          37238,              37077,            36788,            36469,           36156,            35855,          35437},    // index = 18 
        {    5250    ,          37169,              37023,            36739,            36417,           36104,            35796,          35387},    // index = 19 
        {    5000    ,          37086,              36952,            36672,            36346,           36036,            35727,          35317},    // index = 20 
        {    4750    ,          37060,              36931,            36653,            36327,           36018,            35708,          35295},    // index = 21 
        {    4500    ,          36999,              36871,            36592,            36264,           35956,            35646,          35231},    // index = 22 
        {    4250    ,          36977,              36849,            36570,            36241,           35932,            35622,          35207},    // index = 23 
        {    4000    ,          36912,              36779,            36490,            36150,           35832,            35512,          35082},    // index = 24 
        {    3750    ,          36896,              36762,            36475,            36136,           35818,            35498,          35068},    // index = 25 
        {    3500    ,          36866,              36732,            36445,            36108,           35790,            35470,          35040},    // index = 26 
        {    3250    ,          36846,              36712,            36423,            36083,           35763,            35441,          35012},    // index = 27 
        {    3000    ,          36821,              36689,            36396,            36049,           35725,            35400,          34973},    // index = 28 
        {    2750    ,          36765,              36633,            36335,            35980,           35654,            35324,          34896},    // index = 29 
        {    2500    ,          36681,              36549,            36246,            35882,           35552,            35219,          34784},    // index = 30 
        {    2250    ,          36581,              36457,            36151,            35776,           35445,            35107,          34665},    // index = 31 
        {    2000    ,          36456,              36345,            36038,            35653,           35322,            34980,          34535},    // index = 32 
        {    1750    ,          36294,              36203,            35900,            35504,           35178,            34833,          34387},    // index = 33 
        {    1500    ,          36068,              36010,            35713,            35303,           34984,            34634,          34192},    // index = 34 
        {    1250    ,          35934,              35905,            35613,            35186,           34865,            34499,          34058},    // index = 35 
        {    1000    ,          35588,              35567,            35272,            34833,           34505,            34127,          33675},    // index = 36 
        {    750     ,          35381,              35359,            35055,            34605,           34260,            33860,          33382},    // index = 37 
        {    500     ,          35059,              35042,            34729,            34261,           33891,            33457,          32944},    // index = 38 
        {    250     ,          34272,              34225,            33927,            33505,           33149,            32743,          32245},    // index = 39 
        {    0       ,          30000,              30000,            30000,            30000,           30000,            30000,          30000}     // index = 40 
    },// 2nd Dim

    {// 3rd Dim
        ////////////// RESIDUAL CAPACITY  at 15 degrees /////////////////////////////////////////////////////////////////////////////////////////////////
        //     Capacity,        1st mV              2nd mV              3rd mV          4th mV          5th mV              6th mV          7th mV
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Current-15.6Ah,6P     <= 5.0A             5.0~6.0A          6.0~7.8A         7.8~9.9A        9.9~11.9A          11.9~13.9A       13.9~16.7A             
        //Current-18.2Ah,7P     <= 6.0A             6.0~7.0A          7.0~9.1A         9.1~11.7A       11.7~14.0A         14.0~16.3A       TBD: >16.3A             
        //  SOC%,               Pack V,             Pack V,           Pack V,           Pack V,         Pack V,           Pack V,          Pack V,
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        {    10000   ,          41850,             41850,            41850,             41850,          41850,            41850,          41850  },    // index = 00 
        {    9750    ,          39870,             39589,            39299,             39073,          38780,            38556,          38104  },    // index = 01 
        {    9500    ,          39431,             39125,            38808,             38558,          38233,            37981,          37483  },    // index = 02 
        {    9250    ,          39252,             38958,            38646,             38396,          38070,            37813,          37321  },    // index = 03 
        {    9000    ,          39070,             38787,            38479,             38226,          37901,            37640,          37156  },    // index = 04 
        {    8750    ,          38910,             38640,            38334,             38074,          37752,            37488,          37015  },    // index = 05 
        {    8500    ,          38749,             38492,            38186,             37918,          37600,            37336,          36873  },    // index = 06 
        {    8250    ,          38597,             38349,            38047,             37775,          37459,            37194,          36736  },    // index = 07 
        {    8000    ,          38439,             38200,            37902,             37631,          37318,            37051,          36594  },    // index = 08 
        {    7750    ,          38299,             38068,            37776,             37506,          37192,            36920,          36469  },    // index = 09 
        {    7500    ,          38180,             37960,            37671,             37397,          37085,            36809,          36362  },    // index = 10 
        {    7250    ,          38068,             37858,            37568,             37284,          36975,            36702,          36255  },    // index = 11 
        {    7000    ,          37963,             37764,            37470,             37174,          36872,            36603,          36158  },    // index = 12 
        {    6750    ,          37859,             37667,            37375,             37076,          36779,            36514,          36074  },    // index = 13 
        {    6500    ,          37754,             37567,            37282,             36989,          36697,            36436,          36001  },    // index = 14 
        {    6250    ,          37684,             37504,            37225,             36937,          36649,            36389,          35962  },    // index = 15 
        {    6000    ,          37572,             37397,            37123,             36838,          36551,            36290,          35872  },    // index = 16 
        {    5750    ,          37500,             37338,            37069,             36783,          36499,            36234,          35826  },    // index = 17 
        {    5500    ,          37336,             37191,            36929,             36639,          36359,            36090,          35691  },    // index = 18 
        {    5250    ,          37269,             37139,            36882,             36589,          36311,            36040,          35648  },    // index = 19 
        {    5000    ,          37186,             37068,            36815,             36518,          36244,            35972,          35582  },    // index = 20 
        {    4750    ,          37164,             37052,            36801,             36503,          36230,            35956,          35567  },    // index = 21 
        {    4500    ,          37103,             36993,            36742,             36443,          36170,            35895,          35506  },    // index = 22 
        {    4250    ,          37084,             36974,            36724,             36424,          36149,            35871,          35483  },    // index = 23 
        {    4000    ,          37027,             36913,            36653,             36342,          36056,            35767,          35365  },    // index = 24 
        {    3750    ,          37014,             36900,            36640,             36330,          36043,            35754,          35351  },    // index = 25 
        {    3500    ,          36988,             36874,            36614,             36304,          36017,            35727,          35324  },    // index = 26 
        {    3250    ,          36971,             36858,            36597,             36284,          35997,            35705,          35302  },    // index = 27 
        {    3000    ,          36951,             36840,            36577,             36258,          35969,            35676,          35273  },    // index = 28 
        {    2750    ,          36896,             36786,            36520,             36196,          35905,            35610,          35206  },    // index = 29 
        {    2500    ,          36810,             36700,            36431,             36103,          35810,            35511,          35103  },    // index = 30 
        {    2250    ,          36707,             36604,            36335,             36000,          35706,            35403,          34992  },    // index = 31 
        {    2000    ,          36579,             36489,            36222,             35881,          35587,            35277,          34867  },    // index = 32 
        {    1750    ,          36418,             36349,            36087,             35738,          35446,            35130,          34723  },    // index = 33 
        {    1500    ,          36183,             36144,            35889,             35529,          35240,            34915,          34519  },    // index = 34 
        {    1250    ,          36041,             36029,            35781,             35407,          35118,            34779,          34388  },    // index = 35 
        {    1000    ,          35669,             35662,            35410,             35027,          34731,            34381,          33987  },    // index = 36 
        {    750     ,          35433,             35420,            35159,             34768,          34457,            34093,          33681  },    // index = 37 
        {    500     ,          34860,             34809,            34536,             34155,          33823,            33447,          33045  },    // index = 38 
        {    250     ,          33645,             33493,            33223,             32925,          32597,            32269,          31945  },    // index = 39 
        {    0       ,          30000,             30000,            30000,             30000,          30000,            30000,          30000  }     // index = 40 
    },// 3rd Dim


    {// 4th Dim
        ////////////// RESIDUAL CAPACITY  at 25 degrees /////////////////////////////////////////////////////////////////////////////////////////////////
        //     Capacity,        1st mV              2nd mV              3rd mV          4th mV          5th mV              6th mV          7th mV
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Current-15.6Ah,6P     <= 5.0A             5.0~6.0A          6.0~7.8A         7.8~9.9A        9.9~11.9A          11.9~13.9A       13.9~16.7A             
        //Current-18.2Ah,7P     <= 6.0A             6.0~7.0A          7.0~9.1A         9.1~11.7A       11.7~14.0A         14.0~16.3A       TBD: >16.3A             
        //  SOC%,               Pack V,             Pack V,           Pack V,           Pack V,         Pack V,           Pack V,          Pack V,
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        {    10000   ,          41850,             41850,             41850,            41850,          41850,             41850,          41850  },    // index = 00 
        {    9750    ,          39976,             39712,             39449,            39250,          38986,             38789,          38375  },    // index = 01 
        {    9500    ,          39542,             39255,             38966,            38745,          38455,             38237,          37782  },    // index = 02 
        {    9250    ,          39359,             39082,             38798,            38577,          38286,             38062,          37612  },    // index = 03 
        {    9000    ,          39171,             38905,             38628,            38408,          38114,             37882,          37436  },    // index = 04 
        {    8750    ,          39005,             38751,             38479,            38259,          37964,             37724,          37285  },    // index = 05 
        {    8500    ,          38843,             38601,             38331,            38105,          37811,             37568,          37140  },    // index = 06 
        {    8250    ,          38692,             38459,             38190,            37958,          37666,             37420,          37003  },    // index = 07 
        {    8000    ,          38536,             38313,             38047,            37813,          37523,             37276,          36864  },    // index = 08 
        {    7750    ,          38394,             38179,             37918,            37684,          37396,             37146,          36740  },    // index = 09 
        {    7500    ,          38281,             38078,             37816,            37571,          37290,             37045,          36638  },    // index = 10 
        {    7250    ,          38181,             37990,             37721,            37456,          37186,             36952,          36537  },    // index = 11 
        {    7000    ,          38081,             37901,             37628,            37349,          37088,             36863,          36444  },    // index = 12 
        {    6750    ,          37968,             37794,             37528,            37257,          37001,             36779,          36361  },    // index = 13 
        {    6500    ,          37851,             37681,             37427,            37169,          36917,             36696,          36283  },    // index = 14 
        {    6250    ,          37782,             37617,             37369,            37115,          36862,             36636,          36231  },    // index = 15 
        {    6000    ,          37669,             37510,             37265,            37011,          36755,             36521,          36127  },    // index = 16 
        {    5750    ,          37597,             37451,             37210,            36953,          36699,             36461,          36076  },    // index = 17 
        {    5500    ,          37434,             37305,             37070,            36809,          36561,             36325,          35946  },    // index = 18 
        {    5250    ,          37369,             37255,             37025,            36760,          36518,             36283,          35910  },    // index = 19 
        {    5000    ,          37286,             37184,             36959,            36690,          36453,             36217,          35848  },    // index = 20 
        {    4750    ,          37267,             37172,             36949,            36679,          36442,             36205,          35840  },    // index = 21 
        {    4500    ,          37208,             37115,             36892,            36622,          36384,             36144,          35780  },    // index = 22 
        {    4250    ,          37192,             37100,             36877,            36607,          36366,             36120,          35760  },    // index = 23 
        {    4000    ,          37142,             37047,             36816,            36534,          36280,             36022,          35648  },    // index = 24 
        {    3750    ,          37132,             37038,             36806,            36523,          36269,             36009,          35635  },    // index = 25 
        {    3500    ,          37109,             37015,             36783,            36499,          36245,             35984,          35609  },    // index = 26 
        {    3250    ,          37097,             37005,             36772,            36484,          36230,             35970,          35593  },    // index = 27 
        {    3000    ,          37081,             36992,             36757,            36466,          36213,             35953,          35574  },    // index = 28 
        {    2750    ,          37027,             36939,             36704,            36411,          36157,             35895,          35515  },    // index = 29 
        {    2500    ,          36940,             36851,             36616,            36323,          36067,             35803,          35422  },    // index = 30 
        {    2250    ,          36833,             36751,             36518,            36225,          35967,             35698,          35319  },    // index = 31 
        {    2000    ,          36702,             36633,             36406,            36109,          35851,             35574,          35200  },    // index = 32 
        {    1750    ,          36543,             36494,             36273,            35973,          35714,             35427,          35060  },    // index = 33 
        {    1500    ,          36298,             36278,             36066,            35755,          35497,             35196,          34846  },    // index = 34 
        {    1250    ,          36147,             36154,             35949,            35628,          35370,             35059,          34719  },    // index = 35 
        {    1000    ,          35751,             35757,             35548,            35221,          34956,             34635,          34299  },    // index = 36 
        {    750     ,          35485,             35481,             35263,            34931,          34655,             34326,          33981  },    // index = 37 
        {    500     ,          34661,             34577,             34344,            34049,          33755,             33436,          33147  },    // index = 38 
        {    250     ,          33017,             32762,             32519,            32345,          32045,             31795,          31645  },    // index = 39 
        {    0       ,          30000,             30000,             30000,            30000,          30000,             30000,          30000  }     // index = 40 
    }// 4th Dim

};

